Option Explicit

' 初始化一个真实表的表定义 -- 主表
' @param tableAliasVal 当前表的别名
' @param tableNameVal 当前的表名
Public Function createMainRealItem(ByRef tableAliasVal As String, _
    ByRef tableNameVal As String) As IFromItem
    Dim result as DefaultFromItem
    Set result = new DefaultFromItem
    result.InitForReal SqlEnum_FromItemType.MAIN, tableAliasVal, tableNameVal

    Set createMainRealItem = result
End Function

' 初始化一个真实表的表定义 -- 左连接表
' @param tableAliasVal 当前表的别名
' @param tableNameVal 当前的表名
Public Function createLeftJoinRealItem(ByRef tableAliasVal As String, _
    ByRef tableNameVal As String) As IFromItem
    Dim result as DefaultFromItem
    Set result = new DefaultFromItem
    result.InitForReal SqlEnum_FromItemType.LEFT_JOIN, tableAliasVal, tableNameVal

    Set createLeftJoinRealItem = result
End Function

' 初始化一个真实表的表定义 -- 右连接表
' @param tableAliasVal 当前表的别名
' @param tableNameVal 当前的表名
Public Function createRightJoinRealItem(ByRef tableAliasVal As String, _
    ByRef tableNameVal As String) As IFromItem
    Dim result as DefaultFromItem
    Set result = new DefaultFromItem
    result.InitForReal SqlEnum_FromItemType.RIGHT_JOIN, tableAliasVal, tableNameVal

    Set createRightJoinRealItem = result
End Function

' 初始化一个真实表的表定义 -- 内连接表
' @param tableAliasVal 当前表的别名
' @param tableNameVal 当前的表名
Public Function createInnerJoinRealItem(ByRef tableAliasVal As String, _
    ByRef tableNameVal As String) As IFromItem
    Dim result as DefaultFromItem
    Set result = new DefaultFromItem
    result.InitForReal SqlEnum_FromItemType.INNER_JOIN, tableAliasVal, tableNameVal

    Set createInnerJoinRealItem = result
End Function

' 初始化一个真实表的表定义 -- Cross
' @param tableAliasVal 当前表的别名
' @param tableNameVal 当前的表名
Public Function createCrossRealItem(ByRef tableAliasVal As String, _
    ByRef tableNameVal As String) As IFromItem
    Dim result as DefaultFromItem
    Set result = new DefaultFromItem
    result.InitForReal SqlEnum_FromItemType.CROSS, tableAliasVal, tableNameVal

    Set createCrossRealItem = result
End Function

' ----------------------------------------------------------------

' 初始化一个子查询的表定义 -- 主表
' @param tableAliasVal 当前表的别名
' @param sqlTable 子查询对象
Public Function createMainSubItem(ByRef tableAliasVal As String, _
    ByRef sqlTable As SelectSql) As IFromItem
    Dim result as DefaultFromItem
    Set result = new DefaultFromItem
    result.InitForSub SqlEnum_FromItemType.MAIN, tableAliasVal, sqlTable

    Set createMainSubItem = result
End Function

' 初始化一个子查询的表定义 -- 左连接表
' @param tableAliasVal 当前表的别名
' @param sqlTable 子查询对象
Public Function createLeftJoinSubItem(ByRef tableAliasVal As String, _
    ByRef sqlTable As SelectSql) As IFromItem
    Dim result as DefaultFromItem
    Set result = new DefaultFromItem
    result.InitForSub SqlEnum_FromItemType.LEFT_JOIN, tableAliasVal, tableNameVal

    Set createLeftJoinSubItem = result
End Function

' 初始化一个子查询的表定义 -- 右连接表
' @param tableAliasVal 当前表的别名
' @param sqlTable 子查询对象
Public Function createRightJoinSubItem(ByRef tableAliasVal As String, _
    ByRef sqlTable As SelectSql) As IFromItem
    Dim result as DefaultFromItem
    Set result = new DefaultFromItem
    result.InitForSub SqlEnum_FromItemType.RIGHT_JOIN, tableAliasVal, sqlTable

    Set createRightJoinSubItem = result
End Function

' 初始化一个子查询的表定义 -- 内连接表
' @param tableAliasVal 当前表的别名
' @param sqlTable 子查询对象
Public Function createInnerJoinSubItem(ByRef tableAliasVal As String, _
    ByRef sqlTable As SelectSql) As IFromItem
    Dim result as DefaultFromItem
    Set result = new DefaultFromItem
    result.InitForSub SqlEnum_FromItemType.INNER_JOIN, tableAliasVal, sqlTable

    Set createInnerJoinSubItem = result
End Function

' 初始化一个子查询的表定义 -- Cross
' @param tableAliasVal 当前表的别名
' @param sqlTable 子查询对象
Public Function createCrossSubItem(ByRef tableAliasVal As String, _
    ByRef sqlTable As SelectSql) As IFromItem
    Dim result as DefaultFromItem
    Set result = new DefaultFromItem
    result.InitForSub SqlEnum_FromItemType.CROSS, tableAliasVal, sqlTable

    Set createCrossSubItem = result
End Function
